/**
 * Created by Ysssssss on 2021/5/11.
 */
import NP from 'number-precision'


export const priceFenToYuan = price => {
    return (price === '' || price === null || isNaN(price)) ? '' : NP.divide(price, 100)
}


export const priceYuanToFen = price => {
    return (price === '' || price === null || isNaN(price)) ? '' : NP.times(price, 100)
}

export const priceRangePreview = priceRange => {
    let [price1, price2] = priceRange
    if (price1 === price2) {
        return `¥${priceFenToYuan(price1)}`
    } else {
        return `¥${priceFenToYuan(price1)}-¥${priceFenToYuan(price2)}`
    }
}